package com.wngz;

import com.wngz.entity.Teacher;
import com.wngz.entity.User;
import com.wngz.mapper.TeacherMapper;
import com.wngz.mapper.UserMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

@SpringBootTest
public class UserMapperTest01 {

    @Autowired
    private TeacherMapper teacherMapper;

    @Test
    public void insert(){
        Teacher teacher = new Teacher();
        teacher.setName("田丰");
        teacher.setAge(32);
        teacher.setInfo("生物老师");

        int insert = teacherMapper.insert(teacher);
        System.out.println("insert = " + insert);
        System.out.println("teacher = " + teacher);
    }


    @Test
    public void delete(){
        int i = teacherMapper.deleteById(1);
        System.out.println("i = " + i);
    }


    @Test
    public void update(){
        Teacher teacher = new Teacher();
        teacher.setId(3);
        teacher.setName("李筱筱");
        teacher.setAge(25);

        int i = teacherMapper.updateById(teacher);
        System.out.println("i = " + i);
    }


    @Test
    public void list(){
        List<Teacher> teachers = teacherMapper.selectList(null);
        teachers.forEach(System.out::println);
    }


    @Test
    public void listCount(){
        Long count = teacherMapper.selectCount(null);
        System.out.println("count = " + count);
    }
}
